// 使用TS装饰器全局异常管理
const ErrorDecorator = (...args: any[]) => {
  const [, , descriptor] = args
  const method = descriptor.value

  descriptor.value = () => {
    try {
      method()
    } catch (error: any) {
      console.log(`%c错了哦`, 'color:green;font-size:18px;')
      console.log(`%c${error.message}`, 'color:red;font-size:16px;');

    }
  }
}


class MyError {
  @ErrorDecorator
  find() {
    throw new Error('出错了')
  }
}

new MyError().find()
